// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import http from '@/common/httpUtil'

Vue.config.productionTip = false


window.sysModel = {
  baseUrl:'http://localhost:8080',
  userInfo:'user-info-key',
  menuList:'menu-list-key',
  userPermissions:'user-permissions-key',
}



Vue.use(ElementUI);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

Vue.prototype.get = http.get;

Vue.prototype.post = http.post;

// 判断用户是否用相关操作权限
Vue.prototype.isPermission = (permision)=>{
  let perms = null;
  try{
    perms = JSON.parse(localStorage.getItem(window.sysModel.userPermissions)) || [];
  }
  catch(e){
    console.warn('json parse user permission error');
  }
  if(perms.indexOf(permission) >= 0){
    return true;
  }
  return false;
};
